/**
 * json配置举例，更多配置请看 IConfigSchema
 * @author luguoxiang
 * @date 2022/7/5
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
import { IConfigSchema, LgBizSelect } from '@/soar';
import dataSourceApi from '@/pages/system/general/dataSource/api';
import UserSinglePicker from '@/pages/system/auth/user/Picker/SinglePicker.vue';

const fieldList: IConfigSchema<any>[] = [
  {
    field: 'name',
    label: '名称',
    dataType: 'string',
  },
  {
    field: 'dataSourceId',
    label: '数据源id',
    dataType: 'string',
    form: {
      component: LgBizSelect,
      componentProps: {
        data: dataSourceApi.query,
      },
    },
  },
  {
    field: 'dataSourceId',
    label: '数据源',
    dataType: 'string',
    table: {
      colKey: 'dataSourceName',
    },
    detail: {
      field: 'dataSourceName',
    },
    form: false,
    search: false,
  },
  {
    field: 'adminUserId',
    label: '管理员',
    dataType: 'string',
    table: {
      colKey: 'adminUsername',
    },
    detail: {
      field: 'adminUsername',
    },
    form: {
      component: UserSinglePicker,
      componentProps: {
        input: true,
      },
    },
    search: false,
  },
  {
    field: 'expiresTime',
    label: '有效期至',
    dataType: 'datetime',
    table: {
      cell(h, { row }) {
        return row.expiresTime || '永久';
      },
      width: 170,
    },
    detail: {
      formatter(_d, v) {
        return v || '永久';
      },
    },
    form: {
      slots: 'expiresTime',
    },
  },
  {
    field: 'maxUser',
    label: '最大用户数',
    dataType: 'number',
    table: {
      cell(h, { row }) {
        return row.maxUser || '不限';
      },
      width: 100,
    },
    detail: {
      formatter(_d, v) {
        return v || '不限';
      },
    },
    form: {
      slots: 'maxUser',
    },
  },
  {
    field: 'maxOnline',
    label: '最大在线数',
    dataType: 'number',
    table: {
      cell(h, { row }) {
        return row.maxOnline || '不限';
      },
      width: 100,
    },
    detail: {
      formatter(_d, v) {
        return v || '不限';
      },
    },
    form: {
      slots: 'maxOnline',
    },
  },
  {
    field: 'disabled',
    label: '是否禁用',
    dataType: 'boolean',
    table: {
      width: 100,
    },
  },
];

export default fieldList;
